using System;
using Csla;

namespace ENT.GP.Core.Rol
{
    [Serializable]
    public class RolCriterio : BusinessBase<RolCriterio>
    {
        #region Business Methods

        private static PropertyInfo<string> DescripcionProperty = RegisterProperty<string>(o => o.Descripcion, "Name");
        public string Descripcion
        {
            get { return GetProperty(DescripcionProperty); }
            set { SetProperty(DescripcionProperty, value); }
        }

        private static PropertyInfo<string> NombreProperty = RegisterProperty<string>(o => o.Nombre, "Name");
        public string Nombre
        {
            get { return GetProperty(NombreProperty); }
            set { SetProperty(NombreProperty, value); }
        }

        //Nuevo Id Empresa
        private static PropertyInfo<int> IDEmpresaProperty = RegisterProperty<int>(o => o.IDEmpresa, "Name");
        public int IDEmpresa
        {
            get { return GetProperty(IDEmpresaProperty); }
            set { SetProperty(IDEmpresaProperty, value); }
        }

        #endregion

        #region Validation Rules

        protected override void AddBusinessRules()
        {
            // TODO: add validation rules
            //ValidationRules.AddRule(RuleMethod, "");
        }

        #endregion

        #region Authorization Rules

        protected override void AddAuthorizationRules()
        {
            // TODO: add authorization rules
            //AuthorizationRules.AllowWrite("Name", "Role");
        }

        private static void AddObjectAuthorizationRules()
        {
            // TODO: add authorization rules
            //AuthorizationRules.AllowEdit(typeof(UsuarioCriterio), "Role");
        }

        #endregion

        #region Factory Methods

        public static RolCriterio NewRolCriterioRoot()
        {
            return DataPortal.Create<RolCriterio>();
        }
        
        public static RolCriterio GetRolCriterio(int id)
        {
            return DataPortal.Fetch<RolCriterio>(
              new SingleCriteria<RolCriterio, int>(id));
        }

        

        private RolCriterio()
        { /* Require use of factory methods */ }

        #endregion

        
    }
}
